﻿Imports System.Linq
Imports System.Data.Linq

Public Class ContFeeRepository
    Private dc As New TanNamChinhDataContext

    Public Sub New()
        dc = GeneralClassDAL.dc
    End Sub

    Public Function SelectAllRecord() As IQueryable(Of tblContFee)
        Dim companies = From p In dc.tblContFees
                        Select p
        Return companies
    End Function

    Public Function SelectRecordById(ByVal id As Integer) As tblContFee
        Dim ContFee = dc.tblContFees.SingleOrDefault(Function(p As tblContFee) p.ID_ContFee = id)
        Return ContFee
    End Function

    Public Sub Insert(ByVal obj As tblContFee)
        dc.tblContFees.InsertOnSubmit(obj)
        dc.SubmitChanges()
    End Sub

    Public Sub Update(ByVal obj As tblContFee)
        dc.Refresh(RefreshMode.KeepChanges, obj)
        dc.SubmitChanges(ConflictMode.ContinueOnConflict)
    End Sub

    Public Function SelectCustomContFee(ByVal id_cont As Integer) As IQueryable
        Dim companies = From p In dc.tblContFees
                        Where p.ID_Cont = id_cont
                        Select p.ID_ContFee, p.ID_Fee, p.tblFee.FeeName, p.Price, p.InvoiceNo
        Return companies
    End Function

End Class
